package com.xiaoxu.controller;

import com.xiaoxu.damain.UserData;
import com.xiaoxu.service.Registerservice;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.text.SimpleDateFormat;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.time.format.DateTimeFormatter;
import java.util.Date;
import java.util.List;

@RestController
@RequestMapping("/userregister")
@CrossOrigin
public class RegisterController {

    @Autowired
    private Registerservice registerservice;

    @PostMapping
    public Boolean insertUser(@RequestBody UserData reginfo){
        LocalDateTime createDate = LocalDateTime.now();
        String createDate2 = createDate.format(DateTimeFormatter.ofPattern("yyyy-mm-hh"));
        SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
        try{
            reginfo.setUser_createdate(df.parse(createDate2));
        }catch (Exception e) {
            System.out.println("转换失败");
        }
        System.out.println(createDate);
       return registerservice.insertUser(reginfo);
    }
}
